<template>
	<view>
		<view class="item-box">
			WebSocket 连接状态: {{ this.$store.state.isConnect }}
		</view>
		<view class="item-box">
			<u-button type="primary" text="连接WebSocket" @click="connect"></u-button>
		</view>
		<view class="item-box">
			<u-button type="primary" text="关闭WebSocket" @click="close"></u-button>
		</view>
		<view class="item-box">
			<u-button type="primary" text="发送WebSocket消息" @click="sendMsg"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			connect () {
				// 建立websock连接
				uni.$socket.connect()
			},
			close() {
				uni.$socket.close()
			},
			sendMsg() {
				uni.$socket.sendMsg('hello vue')
			}
		}
	}
</script>

<style lang="scss" scoped>
page {
	padding-top: 15px;
}
.item-box {
	margin: 20px;
}
</style>
